package com.junqson.je.recruit.controller;

import com.junqson.je.common.UserHolder;
import com.junqson.je.common.annotation.LoginRequire;
import com.junqson.je.common.model.ApiResult;
import com.junqson.je.common.model.User;
import com.junqson.je.recruit.model.dto.ResumeDTO;
import com.junqson.je.recruit.model.dto.ResumePrsDTO;
import com.junqson.je.recruit.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Descriptions
 * @Company
 * @Author Junqson
 * @Date 2020/2/3 19:38
 * @Version 1.0
 */
@RestController
@RequestMapping("resume")
public class ResumeController {


    @Autowired
    ResumeService resumeService;

    /**
     * 查看简历
     * @return
     */

    @LoginRequire
    @RequestMapping("personal")
    public ApiResult getPersonalResume() {
        User user = UserHolder.get();
        int userId = user.getUserId();
        return ApiResult.success(resumeService.getResume(userId));
    }


    /**
     * 更新简历
     * @param resumeDTO
     * @return
     */
    @LoginRequire
    @RequestMapping("update")
    public ApiResult updateResume(@RequestBody ResumeDTO resumeDTO) {
        User user = UserHolder.get();
        int userId = user.getUserId();
        resumeService.updateResume(resumeDTO, userId);
        return ApiResult.success();
    }
    @LoginRequire
    @RequestMapping("updatePrs")
    public ApiResult updateResumePrs(@RequestBody ResumePrsDTO resumeDTO) {
        User user = UserHolder.get();
        int userId = user.getUserId();
        resumeService.updateResumePrs(resumeDTO, userId);
        return ApiResult.success();
    }
}
